<template>
  <div style="margin: 20px;">
    <el-row :gutter="20">
      <el-col :span="12" :offset="6">
        <el-form :label-position="labelPosition" label-width="80px" :model="user">
          <el-form-item label="用户名">
            <el-input  v-model="userName"></el-input>
          </el-form-item>
<!--          <el-form-item label="密码">-->
<!--            <el-input v-model="user.passWord"></el-input>-->
<!--          </el-form-item>-->
          <el-form-item label="新密码">
            <el-input type="password" v-model="passWord"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm()">确认修改</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "changeinfo",
  data() {
    return {
      user:{
        userName:'',
        passWord:''
      },
      labelPosition: 'right',
      formLabelAlign: {
        name: '',
        region: '',
        type: ''
      }
    };
  },
  methods:{
    submitForm() {

      // this.user = JSON.parse(localStorage.getItem("user"))
      this.$axios.post("/api/user/uodPass",[{username:user.userName},{password:user.password}]).then(res=>{
        if (res.data.code==1){
          alert("修改成功")
          this.$router.push("/login")
        }else{
          alert("信息输入有误,请重新输入")
        }
      })
    },
  }
}
</script>

<style scoped>

</style>
